#pragma once

// Map class which GalaxyMap and SectorMap inherit from
// stores the map and provides functionality for A* pathfinding

#include "Node.h"
#include <vector>

const int gGridSize = 8;

#define DIR_LATERAL
//#define DIR_DIAGONAL


#ifdef DIR_DIAGONAL
const int dir = 8; // number of directions around the current node to check

// combine the x & y values to give the 8 different directions
static int dx[dir]={1, 1, 0, -1, -1, -1,  0,  1};
static int dy[dir]={0, 1, 1,  1,  0, -1, -1, -1};
#endif

#ifdef DIR_LATERAL
const int dir = 4; // number of directions around the current node to check

// combine the x & y values to give the 8 different directions
static int dx[dir]={1, 0, -1,  0};
static int dy[dir]={0, 1,  0, -1};
#endif

class Map
{
public:
	// Constructors/Destructors
	Map();
	virtual ~Map();

	// initializes the Nodes. This is left up to the child class to implement.
	virtual void InitializeNodes(void) = 0;

	// uses the A* algorithm to find the shortest path to the target node.
	// does not perform object avoidance.
	std::vector<Node*> FindPath(Coordinate start, Coordinate goal);

	Node*	GetNode(Coordinate coord);
	Node*	GetNode(int x, int y);

private:
	float HeuristicCostEstimate(Coordinate start, Coordinate goal);
	std::vector<Node*> ReconstructPath(Node* came_from[gGridSize][gGridSize], Node* start, Node* goal);

protected:
	Node* mNodeList[gGridSize][gGridSize];
};